<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--#include file="admin/inc/conn.inc"-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>生成Wiki</title>
</head>

<body>
<%
	strPath = Server.MapPath("wikivip")
	set fs = CreateObject("Scripting.FileSystemObject")
	set folder = fs.GetFolder(strPath)
	Set oFSO = Server.CreateObject("Scripting.FileSystemObject") 
	for each item in folder.Files
		url = item.path
		If Right(url, 13) <> "Framework.htm" Then
			oFSO.DeleteFile(url)
		End If
	next
	set fs = nothing
	set folder = nothing
	
	strSql = "select * from GameWiki "
	Set rs = Server.CreateObject("ADODB.Recordset")
	rs.Open strSql,dbconnection,1,3
	Const ForReading = 1, ForWriting = 2   
	Dim f, objTypeLib   
	Set f = oFSO.OpenTextFile(server.mappath("wikivip\Framework.htm"), ForReading)
	ReadAllTextFileFinal = f.ReadAll   
	Set f = Nothing
	do while not rs.Eof
		strHtml = ""
		strSql = "select Html from GameWikiBoard where BoardID=" & CStr(rs("Id")) &" order by id desc"
		Set rs1 = Server.CreateObject("ADODB.Recordset")
		rs1.Open strSql,dbconnection,1,3
		
		do while not rs1.Eof
			strHtml = strHtml & rs1("Html")
			rs1.movenext
		loop	

		ReadAllTextFile = ReadAllTextFileFinal
		ReadAllTextFile = replace(ReadAllTextFile,"$ID$",rs("ID")) 
		ReadAllTextFile = replace(ReadAllTextFile,"$Hot$",rs("Hot")) 
		ReadAllTextFile = replace(ReadAllTextFile,"$Click$",rs("Click")) 
		ReadAllTextFile = replace(ReadAllTextFile,"$Name$",rs("Name")) 
		ReadAllTextFile = replace(ReadAllTextFile,"$Gamer$",rs("Gamer")) 
		ReadAllTextFile = replace(ReadAllTextFile,"$Title$",rs("Title")) 
		ReadAllTextFile = replace(ReadAllTextFile,"$Text$",rs("Text")) 
		ReadAllTextFile = replace(ReadAllTextFile,"$Pic$",rs("Pic")) 
		ReadAllTextFile = replace(ReadAllTextFile,"$board$", strHtml)
			
		Set objTypeLib = CreateObject("Scriptlet.TypeLib")
		strURL = objTypeLib.Guid
		strURL = Mid(strURL, 1, Len(strURL) - 2)
		rs("URL") = strURL
		rs.update
		
		Set f = oFSO.OpenTextFile(server.mappath("wikivip\" & rs("URL") & ".htm"), ForWriting, True)   
		f.Write ReadAllTextFile
		Set f = Nothing
		Set objTypeLib = Nothing
		rs.MoveNext
	Loop
	set rs = nothing
	set oFSO = nothing
	Response.Write("全部生成完成<br />")
	Response.Write("<meta HTTP-EQUIV=REFRESH CONTENT='1; URL=/'>生成成功，一秒钟后自动返回")
%>
</body>
</html>
<!--#include file="disconn.inc"-->